package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Device;
import com.api.shopapi.entity.dto.DeviceDTO;
import com.api.shopapi.mapper.DeviceMapper;
import com.api.shopapi.service.DeviceService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("DeviceServiceImplOne")
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private DeviceMapper deviceMapper;

    @Override
    public int insert(Device device) {
        return deviceMapper.insert(device);
    }

    @Override
    public Device getByDeviceCode(String deviceCode) {
        return deviceMapper.getByDeviceCode(deviceCode);
    }

    @Override
    public int update(Device device) {
        return deviceMapper.update(device);
    }

    @Override
    public PageInfo<DeviceDTO> getPageList(int pageIndex, int pageSize, String governmentCode, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<DeviceDTO> deviceList =deviceMapper.getPageList(governmentCode,businessCode);
        return new PageInfo<>(deviceList);
    }

    @Override
    public Device getByServeCode(String serveCode) {
        return deviceMapper.getByServeCode(serveCode);
    }

    @Override
    public Device getByImei(String imei) {
        return deviceMapper.getByImei(imei);
    }


    @Override
    public List<Device> getListByBusinessCode(String businessCode){
        return deviceMapper.getListByBusinessCode(businessCode);
    }

}
